package com.starbaba.core.web.taglib;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ComponentTagSupport;

import com.starbaba.core.web.taglib.component.CommonSelectComponent2;
import com.opensymphony.xwork2.util.ValueStack;

@SuppressWarnings("serial")
public class CommonSelectTag2 extends ComponentTagSupport{
	
	private Object list;
	private String id;
	private String name;
	private String value;
	private String emptyOption;
	private String required;
	private String headerKey;
	private String headerValue;

	@Override
	public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
		return new CommonSelectComponent2(stack);
	}
	
	@Override
	protected void populateParams() {
		super.populateParams();
		if(StringUtils.isBlank(headerKey) && !"false".equals(emptyOption)){
			headerKey = "请选择";
		}
		if(StringUtils.isBlank(headerValue)){
			headerValue = "";
		}
		CommonSelectComponent2 commonSelectComponent2 = (CommonSelectComponent2)this.getComponent();
		commonSelectComponent2.setList(list);
		commonSelectComponent2.setId(id);
		commonSelectComponent2.setName(name);
		commonSelectComponent2.setEmptyOption(emptyOption);
		commonSelectComponent2.setValue(value);
		commonSelectComponent2.setRequired(required);
		commonSelectComponent2.setHeaderKey(headerKey);
		commonSelectComponent2.setHeaderValue(headerValue);
    }


	public Object getList() {
		return list;
	}

	public void setList(Object list) {
		this.list = list;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getEmptyOption() {
		return emptyOption;
	}

	public void setEmptyOption(String emptyOption) {
		this.emptyOption = emptyOption;
	}

	public String getRequired() {
		return required;
	}

	public void setRequired(String required) {
		this.required = required;
	}

	public String getHeaderKey() {
		return headerKey;
	}

	public void setHeaderKey(String headerKey) {
		this.headerKey = headerKey;
	}

	public String getHeaderValue() {
		return headerValue;
	}

	public void setHeaderValue(String headerValue) {
		this.headerValue = headerValue;
	}
}
